package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by yaosy on 2017/6/21.
 */
public enum TemplteExceptionEnum implements CustomExceptionCode {

    TEMPLTE_NOT_ID(600, "模板id为空", 900),
    TEMPLTE_NOT_MSG(602, "模板不存在", 900),
    MODIFLY_TEMPLTE_ERROR(603, "该模板文件或目录已存在", 900),
    ADD_TEMPLTE_ERROR(604, "已存在相同模板文件名", 900),
    TEMPLTE_GET_ERROR(605, "查询模板失败！", 900),
    TEMPLTE_MODIFY_ERROR(606, "修改模板失败！", 900),
    TEMPLTE_ADD_ERROR(608, "新增模板失败！", 900),
    TEMPLTE_EXISTS_ERROR(609, "该文件包含子文件！", 900),
    TEMPLTE_DELETE_ERROR(610, "删除文件失败！", 900),
    TEMPLTE_RENAME_ERROR(611, "文件重命名失败！", 900),
    TEMPLTE_WRITER_ERROR(612, "写入模板文件失败！", 900),
    TEMPLTE_CONENT_ERROR(613, "创建文件失败！", 900),
    ADD_TEMPLTE_EXISTS_ERROR(614, "已存在相同模板目录！", 900),
    FAIL_TEMPLTE_ERROR(615, "模板目录创建失败！", 900),
    TEMPLTE_NOT_SITEID(616, "站点id为空！", 900),
    TEMPLTE_NOT_ISDIRECTORY(617, "是否目录为空！", 900),
    TEMPLTE_NOT_EDIT_ISDIRECTORY(618, "顶级目录,不能修改！", 900),
    TEMPLTE_NOT_NAME_BLANK(619, "模板名称不能为空！", 900),
    TEMPLTE_NOT_CONTENT_BLANK(620, "模板内容不能为空！", 900),
    TEMPLTE_PARENT_BLANK(621, "请选择父级节点！", 900),
    TEMPLTE_PARSING_DATA_BLANK(622, "解析模板数据为空！", 900),
    TEMPLTE_PARSING_DATA_FAILED(623, "解析静态模板数失败！", 900),
    TEMPLTE_DATA_BLANK(624, "静态模板数据为空！", 900),
    TEMPLTE_UPLOAD_FAILED(625, "上传文件失败！", 900),
    TEMPLTE_IS_DIRECTORY_FAILED(626, "请选择文件夹目录上传！", 900),
    TEMPLTE_PATH_FAILED(627, "上传路径不存在！", 900),
    TEMPLTE_HAD_PARENT_FAILED(628, "该文件夹包含文件;不能被修改！", 900),
    TEMPLTE_EXISTS_NAME_FAILED(629, "该目录下存在相同文件名,不能上传！", 900),
    TEMPLTE_NOT_CHANNL_ID(630, "分类id为空！", 900),
    TEMPLTE_NOT_EXISTS_MSG(401, "模板不存在", 900),
    TEMPLTE_UPLOAD_EXCEL_MSG(402, "请上传html文件", 900),

    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    TemplteExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }


    public static TemplteExceptionEnum getEnumByCode(Integer code){
        for(TemplteExceptionEnum templteExceptionEnum : TemplteExceptionEnum.values()){
            if(code.equals(templteExceptionEnum.getCode())){
                return templteExceptionEnum;
            }
        }
        return null;
    }
}
